package com.aspose.cells;

import java.util.HashMap;

class zto {
   private Workbook a;
   private zok b;

   zto(zok var1) {
      this.a = var1.a;
      this.b = var1;
   }

   void a(com.aspose.cells.a.f.zj var1) throws Exception {
      zaty var2;
      if (this.b.f != null && this.b.f.size() > 0) {
         var2 = new zaty();
         var2.a(this.a.getWorksheets());
         this.a(var2, this.b.f, var1);
      }

      if (this.b.g != null && this.b.g.size() > 0) {
         var2 = new zaty();
         var2.b(this.a.getWorksheets());
         this.a(var2, this.b.g, var1);
      }

      for(int var8 = 0; var8 < this.b.c.size(); ++var8) {
         zol var3 = (zol)this.b.c.get(var8);
         if (var3.q != null) {
            byte[] var4 = (byte[])var3.a.getBackgroundImage();
            String var5 = "xl/media/" + var3.q;
            com.aspose.cells.b.a.b.zj var6 = com.aspose.cells.b.a.b.zj.a((com.aspose.cells.b.a.d.zm)(new com.aspose.cells.b.a.d.zh(var4)));
            if (var6.e().equals(ImageFormat.getBmp())) {
               var4 = this.a(var6);
               if (var4 == null) {
                  continue;
               }
            }

            com.aspose.cells.a.f.zh var7 = var1.a(var5);
            var7.a(DateTime.getNow());
            var1.a(var7);
            var1.b(var4, 0, var4.length);
            var1.b();
            this.b.a(var3.q);
         }
      }

   }

   private byte[] a(com.aspose.cells.b.a.b.zj var1) throws Exception {
      try {
         com.aspose.cells.b.a.b.za var2 = new com.aspose.cells.b.a.b.za(var1);
         com.aspose.cells.b.a.d.zh var3 = new com.aspose.cells.b.a.d.zh();
         var2.a(var3, ImageFormat.getPng());
         var3.b(0L);
         int var4 = (int)var3.h();
         byte[] var5 = new byte[var4];
         var3.a(var5, 0, var4);
         return var5;
      } catch (Exception var6) {
         return null;
      }
   }

   void a(zaty var1, HashMap var2, com.aspose.cells.a.f.zj var3) throws Exception {
      int var4 = var1.size();

      for(int var5 = 0; var5 < var4; ++var5) {
         zatx var6 = var1.a(var5);
         if (var6.a() != null && var2.containsKey(var5 + 1)) {
            String var7 = (String)var2.get(var5 + 1);
            String var8 = "xl/media/" + var7;
            com.aspose.cells.a.f.zh var9 = var3.a(var8);
            var9.a(DateTime.getNow());
            var3.a(var9);
            var3.b(var6.a(), 0, var6.a().length);
            var3.b();
         }
      }

   }
}
